package net.exoweb.animate.graphics
{
    import flash.events.*;

    import net.exoweb.animate.graphics.*;

    public class GMenu extends GShape
    {
        public var home:GButton;
        public var blog:GButton;
        public var work:GButton;
        public var about:GButton;
        public var contact:GButton;
        public var fan:GFan;

        public function GMenu(color:uint=0xFFFFFF, bm:String="normal")
        {
            super(color, bm);

            home = new GButton("HOME", 0xFFFFFF, color);
            home.display();
            home.x = 20;
            home.y = 20;
            addChild(home);

            blog = new GButton("BLOG", 0xFFFFFF, color);
            blog.display();
            blog.x = 20;
            blog.y = 52;
            addChild(blog);

            work = new GButton("WORK", 0xFFFFFF, color);
            work.display();
            work.x = 20;
            work.y = 84;
            addChild(work);

            about = new GButton("ABOUT", 0xFFFFFF, color);
            about.display();
            about.x = 20;
            about.y = 116;
            addChild(about);

            contact = new GButton("CONTACT", 0xFFFFFF, color);
            contact.display();
            contact.x = 20;
            contact.y = 148;
            addChild(contact);

            fan = new GFan(30, 12, color);
            fan.display();
            fan.x = 100;
            fan.y = 300;
            fan.alpha = 0.5;
            addChild(fan);
            fan.addEventListener(Event.ENTER_FRAME, rotateFan);

            var nail:GNail = new GNail(color, 0);
            nail.display();
            nail.x = 182;
            nail.y = 18;
            nail.scaleX = 1.5;
            nail.scaleY = 1.5;
            addChild(nail);
            nail = new GNail(color, 0);
            nail.display();
            nail.x = 18;
            nail.y = 180;
            nail.scaleX = 1.5;
            nail.scaleY = 1.5;
            addChild(nail);
        }

        public function rotateFan(e:Event):void
        {
            fan.rotation += 14;
        }

        override public function display():void
        {
            graphics.clear();
            graphics.beginFill(color, 0.3);
            graphics.moveTo(0, 0);
            graphics.lineTo(180, 0);
            graphics.lineTo(200, 20);
            graphics.lineTo(200, 300);
            graphics.lineTo(0, 300);
            graphics.endFill();
            graphics.beginFill(color, 1);
            graphics.drawCircle(100, 300, 100);
            graphics.endFill();
            graphics.beginFill(0, 0.8);
            graphics.drawCircle(100, 300, 70);
            graphics.endFill();
        }
    }
}
